<<<<<<< Updated upstream
=======
<template>
  <div style="background: #f4f4f4; overflow: hidden" class="allComment">
    <!-- 帖子评论 -->
    <div class="commentBox" v-for="(item, index) in postComment" :key="index">
      <!-- 删除 -->

      <van-icon
        name="delete-o"
        style="
          position: absolute !important;
          right: 5% !important;
          top: 5% !important;
          font-size: 18px !important;
        "
        @click="deleteIcon(index)"
      />
      <div class="commentTopPic">
        <img :src="item.avatar" alt="" />
      </div>
      <div class="commentName">
        <p>{{ item.userName }}</p>
      </div>
      <div class="commentContent">{{ item.commentContent }}</div>
      <div class="commentThumb">
        <li>
          <van-icon name="good-job-o" /><span>{{ item.zan }}</span>
        </li>
        <van-popup v-model="show" position="bottom" :style="{ height: '20%' }">
          <van-cell-group style="position: relative">
            <van-field
              v-model="message"
              rows="2"
              autosize
              type="textarea"
              maxlength="100"
              placeholder="请输入评论内容"
              show-word-limit
            />
            <button
              style="
                font-size: 12px;
                position: absolute;
                right: 0;
                bottom: -30px;
              "
              @click="replay"
            >
              回复
            </button>
          </van-cell-group>
        </van-popup>
        <li>
          <van-icon name="chat-o" is-link @click="showPopup" /><span>117</span>
        </li>
      </div>

      <div class="replyContent">
        <p class="replayName">{{item.userName}}:</p>
        <p class="replayInfo">{{item.commentContent}}</p>
      </div>

    </div>
    <!-- 第二个 -->
    <div class="commentBox">
      <van-icon
        name="delete-o"
        style="
          position: absolute !important;
          right: 5% !important;
          top: 5% !important;
          font-size: 18px !important;
        "
      />
      <div class="commentTopPic">
        <img src="../assets/zhifeiji.jpg" alt="纸飞机" />
      </div>
      <div class="commentName">
        <p>姓名1</p>
      </div>
      <div class="commentContent">这是我发表的第一篇内容</div>
      <div class="commentThumb">
        <li><van-icon name="good-job-o" /><span>1</span></li>
        <li><van-icon name="chat-o" /><span>117</span></li>
      </div>
      <div class="replyContent">
        <p class="replayName">姓名:</p>
        <p class="replayInfo">回复的内容</p>
      </div>
    </div>
    <div class="commentBox">
      <van-icon
        name="delete-o"
        style="
          position: absolute !important;
          right: 5% !important;
          top: 5% !important;
          font-size: 18px !important;
        "
      />
      <div class="commentTopPic">
        <img src="../assets/zhifeiji.jpg" alt="纸飞机" />
      </div>
      <div class="commentName">
        <p>姓名1</p>
      </div>
      <div class="commentContent">这是我发表的第一篇内容</div>
      <div class="commentThumb">
        <li><van-icon name="good-job-o" /><span>1</span></li>
        <li><van-icon name="chat-o" /><span>117</span></li>
      </div>
      <div class="replyContent">
        <p class="replayName">姓名:</p>
        <p class="replayInfo">回复的内容</p>
      </div>
    </div>
    <div class="commentBox">
      <van-icon
        name="delete-o"
        style="
          position: absolute !important;
          right: 5% !important;
          top: 5% !important;
          font-size: 18px !important;
        "
      />
      <div class="commentTopPic">
        <img src="../assets/zhifeiji.jpg" alt="纸飞机" />
      </div>
      <div class="commentName">
        <p>姓名1</p>
      </div>
      <div class="commentContent">这是我发表的第一篇内容</div>
      <div class="commentThumb">
        <li><van-icon name="good-job-o" /><span>1</span></li>
        <li><van-icon name="chat-o" /><span>117</span></li>
      </div>
      <div class="replyContent">
        <p class="replayName">姓名:</p>
        <p class="replayInfo">回复的内容</p>
      </div>
    </div>
    <div class="commentAll">
      <input
        type="text"
        placeholder="发表评论:"
        class="publishComment"
        v-model="publishComments"
      />
      <van-button type="default" @click="getComment">评论</van-button>
    </div>
  </div>
</template>

<script>
import {
  postComment,
  publishSpeech,
  deleteSpeech,
  requestSpeech,
} from "../api/api";
export default {
  name: "TieziComment",
  data() {
    return {
      postComment: {},
      publishComments: "",
      commentId: "",
      show: false,
      message: "",
    };
  },
  methods: {
    showPopup() {
      this.show = true;
    },
    // 发表评论
    getComment() {
      publishSpeech(this.$route.query.postsId, this.publishComments).then(
        (res) => {
          console.log(res);
        }
      );
    },  
    // 二次评论
    replay() {
      requestSpeech(this.$route.query.postsId,this.commentId,this.message).then((res) => {
        console.log(res);
      });
    },
    // 删除评论
    deleteIcon(a) {
      for (let i = 0; i < this.postComment.length; i++) {
        if (a == i) {
          deleteSpeech(this.commentId).then((res) => {
            console.log(res);
            // this.commentId == "";
          });
        }
      }
    },
  },
  // 评论列表
  created() {
    postComment(this.$route.query.postsId).then((res) => {
      console.log(res);
      if (res.code == 0) {
        this.postComment = res.rows;
        for (let i = 0; i < this.postComment.length; i++) {
          this.commentId = res.rows[i].commentId;
        }
      }
      console.log(res.rows[0].commentId);
    });
    publishSpeech(this.$route.query.postsId, this.publishComments).then(
      (res) => {
        console.log(res);
      }
    );
    deleteSpeech(this.commentId).then((res) => {
      console.log(res);
    });
  },
};
</script>

<style lang="less">
.commentBox {
  position: relative;
  margin: auto;
  margin-top: 5%;
  /* width: 340px; */
  width: 94%;
  /* border: 1px solid black; */
  box-shadow: 2px 2px rgb(233, 230, 230);
  border-radius: 10px;
  background: rgba(235, 200, 134, 0.26);
  margin-bottom: 12%;
}
.allComment > .commentBox:last-child {
  margin-bottom: 12%;
}
.commentTopPic {
  float: left;
  margin-top: 20px;
  margin-left: 50px;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  /* border: 1px solid blue; */
  border-radius: 20px;
}
.commentTopPic > img {
  width: 30px;
  height: 30px;
  border-radius: 15px;
}
.commentName {
  padding-top: 0.5%;
  margin-left: 60px;
  padding-left: 40px;
  vertical-align: middle;
  font-size: 13px;
  text-align: left;
}
.commentName > p {
  padding-top: 16px;
  vertical-align: middle;
}
.commentContent {
  margin: 14px 0 4px 50px;
  width: 250px;
  text-align: left;
  font-size: 14px;

  /* text-indent: 2em; */
}
.commentThumb {
  display: flex;
  flex-direction: row-reverse;
  /* justify-content: space-around; */
  list-style: none;
}
.commentThumb > li:first-child {
  padding-right: 40px;
  text-align: right;
  font-size: 14px;
}
.commentThumb > li:last-child {
  padding-right: 20px;
  font-size: 14px;
  text-align: left;
}
.replyContent {
  overflow: hidden;
  /* margin: 20px 0 4px 50px; */
  /* width: 250px; */
  margin: auto;
  width: 94%;
  /* height: 30px; */
  /* line-height: 10%; */
  text-align: left;
  font-size: 14px;
  box-shadow: 2px 2px #ccc;
  border-radius: 10px;
  background: rgba(235, 200, 134, 0.26);
}
.replyContent p {
  padding-left: 10px;
  float: left;
}
.commentAll {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 5%;
  background-color: white;
}
.publishComment {
  width: 72%;
  height: 5%;
  margin: auto;
  /* margin-left: 6%; */
  position: fixed;
  left: 0;
  bottom: 0;
  font-size: 13px;
  border-radius: 5%;
  border: 1px solid #dcdfe6;
  outline: 0;
}
.commentAll > button {
  position: fixed;
  right: 0;
  bottom: 0;
  float: right;
  margin-right: 1%;
  width: 24%;
  height: 5.6%;
  border-radius: 5%;
}
</style>
>>>>>>> Stashed changes
